<?php
/**
 * Copyright (C), 2021-2021, Shall Buy Life info. Co., Ltd.
 * FileName: OrderCancel
 * Description: 说明
 *
 * @author lwl
 * @Create Date    2021/12/10 20:40
 * @Update Date    2021/12/10 20:40 By lwl
 * @version v1.0
 */

namespace Example\Services\Processor\Order;

use Illuminate\Http\Response;
use YiluTech\YiMQ\Processor\EcProcessor;

class OrderCancel extends EcProcessor
{

    /**
     * FunctionName：validate
     * Description：验证
     * Author：lwl
     * @param $validator
     */
    protected function validate($validator)
    {
        $validator(['ordersn' => 'required']);
    }

    /**
     * FunctionName：do
     * Description：
     * Author：lwl
     * @return bool[]|false[]
     */
    protected function do():array
    {
        $order = $this->data;
        if ($order['ordersn']) {
            $result = OrderService::getInstance()->cancel($order['ordersn']);
            if ($result['code'] == Response::HTTP_OK) {
                return ['result' => true];
            }
        }
        return ['result' => false];
    }
}
